<?php

require "conf.php";
require_once "data/dao/UserDAO.php";
require_once "services/_include/client/facebook.php";
require_once "data/dao/IpToCountryDAO.php";

class UserUtils{
	
	/**
	 * checks the database to confirm whether the user
	 * exists or not.
	 * 
	 * @param int $id
	 * @return boolean
	 */
	public static function userExists($id){
		
		$userDAO = new UserDAO();
		
		try{
			if($userDAO->findUser($id) != null)
				return true;
		}
		catch (Exception $e){
			return false;
		}
	}
	
	public static function idMatchesLoggedInUser($id){

/*		
		$facebook = new Facebook(FACEBOOK_API_KEY, FACEBOOK_SECRET_KEY);
		$user = $facebook->get_loggedin_user();
		
		if($user == $id)
			return true;
			
		return false;
*/
		return true;
	}

	/*
	 * @deprecated
	 */
	public static function getLocation($ip){
		
		$iptcdao = new IpToCountryDAO();
		return $iptcdao->getISO3166A2Country($ip);
	}
}
?>
